package ua.kratik.seabattle.domain;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.annotation.DateTimeFormat.ISO;

import ua.kratik.seabattle.dao.DataObject;

@Entity
@Table(name = "battleRules")
public class BattleRules implements DataObject{
	
	@Id
	@GeneratedValue
	@Column
	private Integer id;
	
	@Column
	private String ruleName;
	
	@Column
	private Integer seaSizeX;
	
	@Column
	private Integer seaSizeY;
	
	@ManyToOne(fetch = FetchType.LAZY, optional = false)
	@JoinColumn(name = "creator_id")
	private User creator;
	
	@Column
	@DateTimeFormat(iso = ISO.DATE_TIME)
	private Date created;

	//DEPENDENT
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "battleRules")
	private List<Fleet> fleet;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getRuleName() {
		return ruleName;
	}

	public void setRuleName(String ruleName) {
		this.ruleName = ruleName;
	}

	public Integer getSeaSizeX() {
		return seaSizeX;
	}

	public void setSeaSizeX(Integer seaSizeX) {
		this.seaSizeX = seaSizeX;
	}

	public Integer getSeaSizeY() {
		return seaSizeY;
	}

	public void setSeaSizeY(Integer seaSizeY) {
		this.seaSizeY = seaSizeY;
	}

	public User getCreator() {
		return creator;
	}

	public void setCreator(User creator) {
		this.creator = creator;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	public List<Fleet> getFleet() {
		return fleet;
	}

	public void setFleet(List<Fleet> fleet) {
		this.fleet = fleet;
	}
}
